<!DOCTYPE html>
<html>
<head>
	<title>添加商品</title>
	<link rel="stylesheet" href="http://cdn.bootcss.com/twitter-bootstrap/2.0.4/css/bootstrap.min.css">
	<style type="text/css">
		body { margin: 20 auto 0 auto; }
	</style>
</head>
<body>
<div class="container">
	<div class="row">
	  	<form action="/admin_1427a/mall/save" method="POST" enctype="multipart/form-data" class="form-horizontal">
	    	<fieldset>
		      	<div id="legend" class="">
		        	<legend class="">商品编辑</legend>
		     	 </div>

		    	<div class="control-group">
					<label class="control-label" for="input01">商品名称</label>
						<div class="controls">
						<input type="text" name="name" placeholder="商品名称" class="input-xlarge" value="{{ $goods ? $goods->name : '' }}" >
					</div>
		        </div>

		    	<div class="control-group">
		            <label class="control-label" for="input01">参考价</label>
		            <div class="controls">
		            	<input type="text" name="original_price" placeholder="参考价" class="input-xlarge" value="{{ $goods ? $goods->original_price : '' }}" >
		            </div>
		        </div>

		    	<div class="control-group">
		            <label class="control-label" for="input01">需小妖币</label>
		            <div class="controls">
		            	<input type="text" name="need_xyb" placeholder="需小妖币" class="input-xlarge" value="{{ $goods ? $goods->need_xyb : '' }}">
		          	</div>
		        </div>

		    	<div class="control-group">
		            <label class="control-label" for="input01">需金币</label>
		            <div class="controls">
		            	<input type="text" name="need_jb" placeholder="需金币" class="input-xlarge" value="{{ $goods ? $goods->need_jb : '' }}">
		          	</div>
		        </div>
				
				<?php
				$goods_types = $goods ? $goods->types : [];
				$type_ids = [];
				foreach( $goods_types as $type ) {
					$type_ids[] = $type->id;
				}
				?>
	
		    	<div class="control-group">
		            <label class="control-label">类型</label>
		          	<div class="controls">
			      		@foreach($types as $t)
						<label class="checkbox">
				        	<input type="checkbox" name="types[]" @if(in_array($t->id, $type_ids)) checked="checked" @endif  value="{{$t->id}}">
				        	{{$t->name}}
				    	</label>	
				  		@endforeach
		  			</div>
		        </div>

		    	<div class="control-group">
		           	<label class="control-label">标签</label>
		          	<div class="controls">
		      			<label class="radio">
		        			<input type="radio" value="1" name="tag" checked="checked">热门
		      			</label>
		      			<label class="radio">
		        			<input type="radio" value="2" name="tag">最新
		      			</label>
		  			</div>
		        </div>

		    	<div class="control-group">
		            <label class="control-label">图片</label>
		          	<div class="controls">
		            	<input class="input-file" name="file" id="fileInput" type="file">
		          	</div>
		        </div>

				<div class="control-group">
					<label class="control-label">缩略图</label>
					<div class="controls">
						<input class="input-file" name="thumbnail" id="fileInput" type="file">
					</div>
				</div>

		    	<div class="control-group">
		            <label class="control-label">说明</label>
		          	<div class="controls">
		            	<div class="textarea">
		                    <textarea type="" name="description" class="">{{$goods ? $goods->description : ''}}</textarea>
		            	</div>
		          	</div>
		        </div>

				<div class="control-group">
					<input type="hidden" name="_token" value="{{ csrf_token() }}">
					<input type="hidden" name="id" value="{{ $goods ? $goods->id : 0 }}">
					<label class="control-label"></label>
					<div class="controls">
						<button type="submit" class="btn btn-default">提交</button>
					</div>
				</div>
	    	</fieldset>
	  	</form>
	</div>
</div>
</body>
</html>
